home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10765 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: presby.edu!jtbell
  3. From: jtbell@presby.edu (Jon Bell)
  4. Subject: Re: Initializing each element in an array of classes
  5. Message-ID: <Do1A90.33L@presby.edu>
  6. Date: Sun, 10 Mar 1996 04:10:11 GMT
  7. References: <4hssvm$178_001@basmith1.iquest.net>
  8. Organization: Presbyterian College, Clinton, South Carolina USA
  9.  
  10.  Brian Smith <basmith@iquest.net> wrote:
  11. >class Dot {
  12. >  int X;
  13. >  int Y;
  14. >  Dot(void);
  15. >  Dot(int InitX, int InitY, int InitSize = 1) // default for InitSize is 1
  16. >};
  17.  
  18. >class Box {
  19. >  int i;
  20. >  int j;
  21. >  Dot DotArray[3];
  22. >  etc...
  23. >}
  24.  
  25. >How can I create this array of Dots with the X and Y values of, for example, 
  26. >(1,1), (2,2), and (3,3)? The Borland Turbo C++ manual is of no help at all.
  27.  
  28. Perhaps by writing a constructor for class Box, which takes either six 
  29. ints or three Dots as arguments, and stuffs their values into DotArray?  
  30. Sort of like your constructor for Dot?  Or am I missing something here?
  31.  
  32. -- 
  33. Jon Bell <jtbell@presby.edu>                        Presbyterian College
  34. Dept. of Physics and Computer Science        Clinton, South Carolina USA
  35.